home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / bit / src / forms / FORMS / forms.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  18KB  |  643 lines

  1. /*
  2.  * forms.c
  3.  * 
  4.  * This file is part of the basis of the Forms Library.
  5.  *
  6.  * It contains the routines for building up forms and for handling the
  7.  * interaction with the user.
  8.  *
  9.  * Written by Mark Overmars
  10.  *
  11.  * Version 2.2 c
  12.  * Date Jun 21, 1993
  13.  */
  14.  
  15. #include <stdio.h>
  16. #include <sys/time.h>
  17. #include "gl/gl.h"
  18. #include "gl/device.h"
  19. #include "forms.h"
  20.  
  21. #if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
  22. extern "C" {
  23. #endif
  24. extern int sginap (long);
  25. #if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
  26. }
  27. #endif
  28.  
  29. FL_FORM *fl_current_form = NULL;
  30. static FL_OBJECT *fl_current_group = NULL;
  31.  
  32. FL_FORM *fl_bgn_form(int type,float w,float h)
  33. /* Starts a form definition */
  34. {
  35.   fl_init();
  36.   if (fl_current_form != NULL)
  37.     { fl_error("fl_bgn_form","You forgot calling fl_end_form."); }
  38.   fl_current_form = fl_make_form(w,h);
  39.   fl_add_box(type,0.0,0.0,w,h,"");
  40.   return fl_current_form;
  41. }
  42.  
  43. void fl_end_form()
  44. /* Ends a form definition */
  45. {
  46.   if (fl_current_form == NULL)
  47.     { fl_error("fl_end_form","Ending form definition of NULL form."); return; }
  48.   fl_current_form = NULL;
  49. }
  50.  
  51. void fl_addto_form(FL_FORM *form)
  52. /* Reopens a form for input */
  53. {
  54.   if (fl_current_form != NULL)
  55.     { fl_error("fl_addto_form","You forgot calling fl_end_form"); }
  56.   if (form == NULL)
  57.     { fl_error("fl_addto_form","Adding to NULL form."); return; }
  58.   fl_current_form = form;
  59. }
  60.  
  61. FL_OBJECT *fl_bgn_group()
  62. /* Starts a group definition */
  63. {
  64.   if (fl_current_form == NULL)
  65.     { fl_error("fl_bgn_group","Starting group in NULL form."); return NULL;}
  66.   if (fl_current_group != NULL)
  67.     { fl_error("fl_bgn_group","You forgot calling fl_end_group."); fl_end_group();}
  68.   fl_current_group = fl_make_object(FL_BEGIN_GROUP,0,0.0,0.0,0.0,0.0,"",NULL);
  69.   fl_add_object(fl_current_form,fl_current_group);
  70.   return fl_current_group;
  71. }
  72.  
  73. FL_OBJECT *fl_end_group()
  74. /* Ends a group definition */
  75. {
  76.   FL_OBJECT *ob;
  77.   if (fl_current_form == NULL)
  78.     { fl_error("fl_end_group","Ending group in NULL form."); return NULL; }
  79.   if (fl_current_group == NULL)
  80.     { fl_error("fl_end_group","Ending NULL group."); return NULL; }
  81.   fl_current_group = NULL;
  82.   ob = fl_make_object(FL_END_GROUP,0,0.0,0.0,0.0,0.0,"",NULL);
  83.   fl_add_object(fl_current_form,ob);
  84.   return ob;
  85. }
  86.  
  87. /************************ Doing the Interaction *************************/
  88.  
  89. #define MAX_FORM    40
  90.  
  91. static FL_FORM *forms[MAX_FORM];    /* The forms being shown. */
  92. static int formnumb = 0;         /* Their number. */
  93. static FL_FORM *mouseform = NULL;       /* The current form under mouse*/
  94. static FL_OBJECT *pushobj = NULL;    /* latest pushed object */
  95. static FL_OBJECT *mouseobj = NULL;      /* object under the mouse */
  96.  
  97. static void reshape_form(FL_FORM *form)
  98. /* Corrects the shape of the form based on the shape of its window */
  99. {
  100.     long w, h;
  101.     fl_save_user_window();
  102.     fl_set_forms_window(form);
  103.     getsize(&w,&h);
  104.     getorigin(&(form->x),&(form->y));
  105.     if ( w != (long) form->w || h != (long) form->h)
  106.     fl_set_form_size(form, w, h);
  107.     ortho2(-0.5, (int) form->w - 0.5, -0.5, (int) form->h - 0.5);
  108.     fl_restore_user_window();
  109. }
  110.  
  111. static void reshape_window(FL_FORM *form)
  112. /* Corrects the shape of the window based on the shape of the form */
  113. {
  114.     if (form->visible <= 0) return;
  115.     fl_save_user_window();
  116.     fl_set_forms_window(form);
  117.     winposition((long) form->x, (long) (form->x+form->w -1),
  118.          (long) form->y, (long) (form->y+form->h -1));   
  119.     fl_restore_user_window();
  120. }
  121.  
  122. void fl_scale_form(FL_FORM *form, float xsc, float ysc)
  123. /* Scales a form with the given scaling factors. */
  124. {
  125.     FL_OBJECT *obj;
  126.     if (form == NULL)
  127.       { fl_error("fl_scale_form","Scaling NULL form."); return;}
  128.     obj = form->first;
  129.     while (obj != NULL)
  130.     {
  131.       obj->x = obj->x * xsc;
  132.       obj->y = obj->y * ysc;
  133.       obj->w = obj->w * xsc;
  134.       obj->h = obj->h * ysc;
  135.       obj = obj->next;
  136.     }
  137.     form->w = form->w * xsc;
  138.     form->h = form->h * ysc;
  139.     reshape_window(form);
  140. }
  141.  
  142. void fl_set_form_size(FL_FORM *form, long w, long h)
  143. /* Sets the size of the form on the screen. */
  144. {
  145.     if (form == NULL)
  146.     { fl_error("fl_set_form_size","Changing size of NULL form."); return;}
  147.     fl_scale_form(form, ((float) w) / form->w, ((float) h) / form->h);
  148. }
  149.  
  150. void fl_set_form_position(FL_FORM *form, long x, long y)
  151. /* Sets the position of the form on the screen. */
  152. {
  153.     if (form == NULL)
  154.     { fl_error("fl_set_form_position","Changing position NULL form."); return;}
  155.     form->x = x; form->y = y;
  156.     reshape_window(form);
  157. }
  158. void fl_set_form_hotspot(FL_FORM *form, float x, float y)
  159. /* Sets the position of the form on the screen. */
  160. {
  161.   if (form == NULL)
  162.     { fl_error("fl_set_form_hotspot","setting hotspot for NULL form.");
  163. return;}
  164.   form->hotx = x; form->hoty = y;
  165. }
  166.  
  167. long fl_show_form(FL_FORM *form,int place,int border,const char *name)
  168. /* Displays a particular form. Returns window handle. */
  169. {
  170.   long screenw,screenh;
  171.   if (formnumb == MAX_FORM)
  172.     { fl_error("fl_show_form","Can show only 40 forms."); return -1; }
  173.   if (form == NULL)
  174.     { fl_error("fl_show_form","Trying to display NULL form."); return -1;}
  175.   if (form->visible ) return form->window;
  176.  
  177.   fl_save_user_window();  
  178.   forms[formnumb++] = form;
  179.   form->deactivated = 0;
  180.   screenw = getgdesc(GD_XPMAX); screenh = getgdesc(GD_YPMAX);
  181.  
  182.   if (place == FL_PLACE_SIZE)
  183.     prefsize( (int) form->w, (int) form->h);
  184.   else if (place == FL_PLACE_ASPECT)
  185.     keepaspect( (int) form->w, (int) form->h);
  186.   else if (place != FL_PLACE_FREE)
  187.   {
  188.     switch(place)
  189.     {
  190.     case FL_PLACE_CENTER:
  191.         form->x = (int) ((screenw - form->w)/2.);
  192.     form->y = (int) ((screenh - form->h)/2.);
  193.     break;
  194.     case FL_PLACE_MOUSE:
  195.     form->x = (int) (getvaluator(MOUSEX) - 0.5*form->w);
  196.     form->y = (int) (getvaluator(MOUSEY) - 0.5*form->h);
  197.     break;
  198.     case FL_PLACE_FULLSCREEN:
  199.     form->x = 0;
  200.     form->y = 0;
  201.     fl_set_form_size(form, screenw, screenh);
  202.     break;
  203.     case FL_PLACE_HOTSPOT:   /*TCZ */
  204.         if(form->hotx < 0.0) {/* never set */
  205.            form->x = (int) (getvaluator(MOUSEX) - 0.5*form->w);
  206.            form->y = (int) (getvaluator(MOUSEY) - 0.5*form->h);
  207.         }
  208.         else {
  209.           long it = border ? 12:1;
  210.         if((form->x = (getvaluator(MOUSEX) - form->hotx)) < it) {
  211.            form->x  = it;
  212.            setvaluator(MOUSEX, form->x + form->hotx, 0, getgdesc(GD_XPMAX));
  213.          }
  214.          if(form->x > (long)(screenw - form->w -it)) {
  215.            form->x = (long) (screenw - form->w - it);
  216.            setvaluator(MOUSEX, form->x + form->hotx, 0, getgdesc(GD_XPMAX));
  217.          }
  218.          if((form->y = (getvaluator(MOUSEY) - form->hoty)) < it) {
  219.            form->y  = it;
  220.            setvaluator(MOUSEY, form->y + form->hoty, 0, getgdesc(GD_YPMAX));
  221.          }
  222.          if(form->y > (long)(screenh - form->h -it)) {
  223.            form->y = (long) (screenh - form->h - it);
  224.            setvaluator(MOUSEY, form->y + form->hoty, 0, getgdesc(GD_YPMAX));
  225.          }
  226.        }
  227.        break;
  228.     }
  229.     if(place == FL_PLACE_POSITION){
  230.     /* Correct form position */
  231.     if (form->x < 0) form->x = screenw - form->w + form->x -1.0;
  232.     if (form->y < 0) form->y = screenh - form->h + form->y -1.0;
  233.     }
  234.  
  235.     if (form->x < 0) form->x = 0.0;
  236.     if (form->x > screenw - form->w) form->x = screenw - form->w;
  237.  
  238.     if (form->y < 0) form->y = 0.0;
  239.     if (form->y > screenh - form->h) form->y = screenh - form->h;
  240.  
  241.     prefposition((long) form->x, (long) (form->x+form->w -1),
  242.          (long) form->y, (long) (form->y+form->h -1));
  243.   }
  244.  
  245.   if (! border) noborder();
  246.   if (name == NULL)
  247.     form->window = winopen("Form");
  248.   else
  249.     form->window = winopen((char *)name);
  250.   form->visible = 1;
  251.   if (form->doublebuf) doublebuffer();
  252.   if (fl_rgbmode) RGBmode();
  253.   gconfig();
  254.   ortho2(-0.5, (int) form->w - 0.5, -0.5, (int) form->h - 0.5);
  255.   
  256.   /* Clear window */
  257.   fl_color(FL_COL1);
  258.   clear();
  259.   if (form->doublebuf) swapbuffers();
  260.   
  261.   /* Queue the devices */
  262.   qdevice(MOUSE3); qdevice(MOUSE2); qdevice(MOUSE1);
  263.   qdevice(KEYBD);
  264.   qdevice(LEFTARROWKEY); qdevice(RIGHTARROWKEY);
  265.   qdevice(UPARROWKEY); qdevice(DOWNARROWKEY);
  266.   qdevice(WINQUIT);
  267.   qdevice(WINFREEZE);
  268.   qdevice(WINTHAW);
  269.  
  270.   reshape_form(form);  
  271.   fl_redraw_form(form);
  272.   fl_restore_user_window();
  273.   return form->window;
  274. }
  275.  
  276. void fl_hide_form(FL_FORM *form)
  277. /* Hides a particular form */
  278. {
  279.   int i;
  280.   FL_OBJECT *obj;
  281.   if (form == NULL)
  282.     { fl_error("fl_hide_form","Hiding NULL form."); return; }
  283.   if (form->window < 0 )
  284.     { fl_error("fl_hide_form","Hiding invisible form."); return; }
  285.   
  286.   fl_save_user_window();
  287.   fl_set_forms_window(form);
  288.   for (i=0; i<formnumb; i++)
  289.     if (form == forms[i]) forms[i] = forms[--formnumb];
  290.   if (mouseobj != NULL && mouseobj->form == form)
  291.   {
  292.     obj = mouseobj; mouseobj = NULL;
  293.     fl_handle_object(obj,FL_LEAVE,0.0,0.0,0);
  294.   }
  295.   if (pushobj != NULL && pushobj->form == form)
  296.   {
  297.     obj = pushobj; pushobj = NULL;
  298.     fl_handle_object(obj,FL_RELEASE,0.0,0.0,0);
  299.   }
  300.   if (form->focusobj != NULL)
  301.   {
  302.     obj = form->focusobj;
  303.     fl_handle_object(form->focusobj,FL_UNFOCUS,0.0,0.0,0);
  304.     fl_handle_object(obj,FL_FOCUS,0.0,0.0,0);
  305.   }
  306.   winclose(form->window);
  307.   form->window = -1;
  308.   form->deactivated = 1;
  309.   form->visible = 0;
  310.   fl_restore_user_window();
  311. }
  312.  
  313. void fl_activate_form(FL_FORM *form)
  314. /* activates a form */
  315. {
  316.   if (form == NULL)
  317.     { fl_error("fl_activate_form","Activating NULL form."); return; }
  318.   if (form->deactivated) form->deactivated--;
  319. }
  320.  
  321. void fl_deactivate_form(FL_FORM *form)
  322. /* deactivates a form */
  323. {
  324.   if (form == NULL)
  325.     { fl_error("fl_deactivate_form","Deactivating NULL form."); return; }
  326.   if (!form->deactivated && mouseobj != NULL && mouseobj->form == form)
  327.       fl_handle_object(mouseobj,FL_LEAVE,0.0,0.0,0);
  328.   form->deactivated++;
  329. }
  330.  
  331. void fl_activate_all_forms()
  332. /* activates all forms */
  333. {
  334.   int i;
  335.   for (i=0; i<formnumb; i++) fl_activate_form(forms[i]);
  336. }
  337.  
  338. void fl_deactivate_all_forms()
  339. /* deactivates all forms */
  340. {
  341.   int i;
  342.   for (i=0; i<formnumb; i++) fl_deactivate_form(forms[i]);
  343. }
  344.  
  345. static void fl_handle_form(FL_FORM *form, int event, int key)
  346. /* updates a form according to an event */
  347. {
  348.   int i;
  349.   FL_OBJECT *obj, *obj1;
  350.   float xx,yy;
  351.   if (form == NULL || ! form->visible) return;
  352.   if (form->deactivated && event != FL_DRAW) return;
  353.   if (event != FL_STEP) fl_set_forms_window(form);  /* Avoid unnecessary winsets */
  354.   if (event != FL_STEP && event != FL_DRAW)
  355.   {
  356.     fl_get_mouse(&xx,&yy);
  357.     obj = fl_find_last(form,FL_FIND_MOUSE,xx,yy);
  358.   }
  359.   switch (event)
  360.   {
  361.     case FL_DRAW:       /* form must be redrawn */
  362.     reshapeviewport();
  363.     reshape_form(form);
  364.     fl_redraw_form(form);
  365.     break;
  366.     case FL_ENTER:    /* Mouse did enter the form */
  367.     mouseobj = obj;
  368.     fl_handle_object(mouseobj,FL_ENTER,xx,yy,0);
  369.     break;
  370.     case FL_LEAVE:    /* Mouse did leave the form */
  371.     fl_handle_object(mouseobj,FL_LEAVE,xx,yy,0);
  372.     mouseobj = NULL;
  373.     break;
  374.     case FL_MOUSE:    /* Mouse position changed in the form */
  375.     if (pushobj != NULL)
  376.       fl_handle_object(pushobj,FL_MOUSE,xx,yy,0);
  377.     else if (obj != mouseobj)
  378.     {
  379.       fl_handle_object(mouseobj,FL_LEAVE,xx,yy,0);
  380.       fl_handle_object(mouseobj = obj,FL_ENTER,xx,yy,0);
  381.     }
  382.     else if (mouseobj != NULL)
  383.       fl_handle_object(mouseobj,FL_MOVE,xx,yy,0);
  384.     break;
  385.     case FL_PUSH:        /* Mouse was pushed inside the form */
  386.     /* change input focus */
  387.     if ( obj != NULL && obj->input && form->focusobj != obj)
  388.     {
  389.       fl_handle_object(form->focusobj,FL_UNFOCUS,xx,yy,0);
  390.       fl_handle_object(obj,FL_FOCUS,xx,yy,0);
  391.     }
  392.     /* handle a radio button */
  393.     if (obj != NULL && obj->radio)
  394.     {
  395.       obj1 = obj;
  396.       while (obj1->prev != NULL && obj1->objclass != FL_BEGIN_GROUP)
  397.         obj1 = obj1->prev;
  398.       while (obj1 != NULL && obj1->objclass != FL_END_GROUP)
  399.       {
  400.         if ( obj1->radio && obj1->pushed )
  401.         {
  402.           fl_handle_object_direct(obj1,FL_PUSH,xx,yy,0);
  403.           fl_handle_object_direct(obj1,FL_RELEASE,xx,yy,0);
  404.           obj1->pushed = 0;
  405.         }
  406.         obj1 = obj1->next;
  407.       }
  408.     }
  409.     /* push the object */
  410.     fl_handle_object(obj,FL_PUSH,xx,yy,key);
  411.     pushobj = obj;
  412.     break;
  413.     case FL_RELEASE:  /* Mouse was released inside the form */
  414.     obj = pushobj; pushobj = NULL;
  415.     fl_handle_object(obj,FL_RELEASE,xx,yy,key);
  416.     break;
  417.     case FL_KEYBOARD: /* A key was pressed */
  418.     /* Check whether the <Alt> key is pressed */
  419.     if (getbutton(LEFTALTKEY) || getbutton(RIGHTALTKEY)) key +=128;
  420.     
  421.     /* Check whether an object has this as shortcut. */
  422.     obj1 = form->first;
  423.     while (obj1 != NULL)
  424.     {
  425.       i = -1;
  426.       while (obj1->shortcut[++i] != '\0')
  427.         if (obj1->shortcut[i] == key)
  428.             {
  429.           fl_handle_object(obj1,FL_SHORTCUT,xx,yy,key);
  430.           return;
  431.         }
  432.       obj1 = obj1->next;
  433.         }
  434.     if ( form->focusobj != NULL)
  435.     {
  436.       if ( (key == 9 || key == 13) && !form->focusobj->wantall)
  437.       {
  438.         obj = fl_find_object(form->focusobj->next,FL_FIND_INPUT,0.,0.);
  439.         if (obj == NULL) obj = fl_find_first(form,FL_FIND_INPUT,0.,0.);
  440.         fl_handle_object(form->focusobj,FL_UNFOCUS,xx,yy,0);
  441.         fl_handle_object(obj,FL_FOCUS,xx,yy,0);
  442.       }
  443.       else
  444.         fl_handle_object(form->focusobj,FL_KEYBOARD,xx,yy,key);
  445.     }
  446.     break;
  447.     case FL_STEP:       /* A simple step */
  448.     obj1 = fl_find_first(form,FL_FIND_AUTOMATIC,0.0,0.0);
  449.     if (obj1 != NULL) fl_set_forms_window(form);    /* set only if required */
  450.     while (obj1 != NULL)
  451.     {
  452.       fl_handle_object(obj1,FL_STEP,xx,yy,0);
  453.       obj1 = fl_find_object(obj1->next,FL_FIND_AUTOMATIC,0.0,0.0);
  454.         }
  455.     break;
  456.   }
  457. }
  458.  
  459. /***************
  460.   Routine to check for events 
  461. ***************/
  462.  
  463. static long lastsec = 0;
  464. static long lastusec = 0;
  465. static struct timeval tp;
  466. static struct timezone tzp;
  467.  
  468. static void reset_time()
  469. /* Resets the timer */
  470. {
  471.   gettimeofday(&tp,&tzp);
  472.   lastsec = tp.tv_sec; lastusec = tp.tv_usec;
  473. }
  474.  
  475. static float time_passed()
  476. /* Returns the time passed since the last call */
  477. {
  478.   gettimeofday(&tp,&tzp);
  479.   return (float) (tp.tv_sec - lastsec) + 0.000001 * (tp.tv_usec - lastusec);
  480. }
  481.  
  482. static void do_interaction_step(int wait)
  483. /* Checks the devices and takes action accordingly.*/
  484. {
  485.   int i;
  486.   Device dev;
  487.   short val;
  488.   /* check devices */
  489.   if (!qtest())
  490.   {
  491.     if (time_passed()<0.01)
  492.       { if (wait) sginap(1); else return;}
  493.     reset_time();
  494.   }
  495.   /* Ignore NULLDEV events (when used over network) */
  496.   do
  497.     if (!qtest()) dev = TIMER3; else dev = (Device) qread(&val);
  498.   while(dev == NULLDEV);
  499.   if (mouseform == NULL && dev != REDRAW && dev != INPUTCHANGE && dev != TIMER3 
  500.     && dev != WINFREEZE && dev != WINTHAW)
  501.     { fl_qenter(dev,val); return; }
  502.   switch (dev)
  503.   {
  504.     case WINFREEZE:
  505.       for (i=0; i<formnumb; i++)
  506.         if (forms[i]->window == val)
  507.           { fl_deactivate_form(forms[i]); return;}
  508.       fl_qenter(dev,val);
  509.       break;
  510.     case WINTHAW:
  511.       for (i=0; i<formnumb; i++)
  512.         if (forms[i]->window == val)
  513.           { fl_activate_form(forms[i]); return;}
  514.       fl_qenter(dev,val);
  515.       break;
  516.     case REDRAW:
  517.         for (i=0; i<formnumb; i++)
  518.       if (forms[i]->window == val)
  519.         {fl_handle_form(forms[i],FL_DRAW,0);return;}
  520.     fl_qenter(dev,val);
  521.     break;
  522.     case MOUSE1:
  523.     case MOUSE2:
  524.     case MOUSE3:
  525.     if (val)
  526.     {
  527.       if (getbutton(PAUSEKEY))
  528.             fl_show_message("FORMS LIBRARY","version 2.2a", "Written by Mark Overmars");
  529.       else
  530.         fl_handle_form(mouseform,FL_PUSH,dev-MOUSE1+1);
  531.     }
  532.     else
  533.       fl_handle_form(mouseform,FL_RELEASE,dev-MOUSE1+1);
  534.     break;
  535.     case INPUTCHANGE:
  536.     /* leaving a window can cause val to be 256 (rather than 0) when
  537.      * used over the network.
  538.      */
  539.     if ((val & 0xff) == 0)
  540.         {
  541.       if (mouseform == NULL)
  542.             fl_qenter(dev,val);
  543.           else
  544.         { fl_handle_form(mouseform,FL_LEAVE,0); mouseform = NULL; }
  545.         }
  546.     else
  547.     {
  548.       if (mouseform != NULL)
  549.         { fl_handle_form(mouseform,FL_LEAVE,0); mouseform = NULL; }
  550.       for (i=0; i<formnumb; i++)
  551.         if (forms[i]->window == val)
  552.         { mouseform=forms[i]; fl_handle_form(mouseform,FL_ENTER,0); return;}
  553.        fl_qenter(dev,val);
  554.     }
  555.     break;
  556.     case LEFTARROWKEY:
  557.     if (val) fl_handle_form(mouseform,FL_KEYBOARD,1);
  558.     break;
  559.     case RIGHTARROWKEY:
  560.     if (val) fl_handle_form(mouseform,FL_KEYBOARD,2);
  561.     break;
  562.     case UPARROWKEY:
  563.     if (val) fl_handle_form(mouseform,FL_KEYBOARD,3);
  564.     break;
  565.     case DOWNARROWKEY:
  566.     if (val) fl_handle_form(mouseform,FL_KEYBOARD,4);
  567.     break;
  568.     case KEYBD:
  569.     fl_handle_form(mouseform,FL_KEYBOARD,val);
  570.     break;
  571.     case TIMER3:
  572.           fl_handle_form(mouseform,FL_MOUSE,0);
  573.         for (i=0; i<formnumb; i++) fl_handle_form(forms[i],FL_STEP,0);
  574.     break;
  575.     default:
  576.         fl_qenter(dev,val);
  577.   }
  578. }
  579.  
  580. void fl_treat_interaction_events(int wait)
  581. /* Handles all events in the input queue */
  582. {
  583.   fl_save_user_window();
  584.   do do_interaction_step(wait); while (qtest());
  585.   fl_restore_user_window();
  586. }
  587.  
  588. FL_OBJECT *fl_check_forms()
  589. /* Checks all forms. Does not wait. */
  590. {
  591.   FL_OBJECT *obj;
  592.   fl_save_user_window();
  593.   if ( (obj = fl_object_qread()) == NULL)
  594.   {
  595.     fl_treat_interaction_events(FALSE);
  596.     fl_treat_user_events();
  597.     obj = fl_object_qread();
  598.   }
  599.   fl_restore_user_window();
  600.   return obj;
  601. }
  602.  
  603. FL_OBJECT *fl_do_forms()
  604. /* Checks all forms. Waits if nothing happens. */
  605. {
  606.   FL_OBJECT *obj;
  607.   fl_save_user_window();
  608.   while (1)
  609.   {
  610.     if ( (obj = fl_object_qread()) != NULL)
  611.       { fl_restore_user_window(); return obj; }
  612.     fl_treat_interaction_events(TRUE);
  613.     fl_treat_user_events();
  614.   }
  615. }
  616.  
  617. FL_OBJECT *fl_check_only_forms()
  618. /* Same as fl_check_forms but never returns FL_EVENT. */
  619. {
  620.   FL_OBJECT *obj;
  621.   fl_save_user_window();
  622.   if ( (obj = fl_object_qread()) == NULL)
  623.   {
  624.     fl_treat_interaction_events(FALSE);
  625.     obj = fl_object_qread();
  626.   }
  627.   fl_restore_user_window();
  628.   return obj;
  629. }
  630.  
  631. FL_OBJECT *fl_do_only_forms()
  632. /* Same as fl_do_forms but never returns FL_EVENT. */
  633. {
  634.   FL_OBJECT *obj;
  635.   fl_save_user_window();
  636.   while (1)
  637.   {
  638.     if ( (obj = fl_object_qread()) != NULL)
  639.       { fl_restore_user_window(); return obj; }
  640.     fl_treat_interaction_events(TRUE);
  641.   }
  642. }
  643.